<?php 
return [
	'name' => '轮播',
	'manager_url' => plugin_url('/slide/admin/index'),
	'description' => '轮播插件',
	'version' => '1.0.0',
	'author' => '谢蕾',
	'weburl' => 'http://www.ebcms.com/',
	'hooks'=>[
		'home_slide' => [function(){
			$view = new \mylib\View(\mylib\Config::get('view'));
			echo $view -> fetch(__DIR__ . '/tpl.php');
		}]
	],
	'install' => function(){
		$sqls = [];
		$sqls[] = "DROP TABLE IF EXISTS `ebcms_slide`;";
		$sqls[] = <<<str
CREATE TABLE `ebcms_slide` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '节点ID',
  `title` varchar(255) DEFAULT '' COMMENT '标题',
  `url` varchar(255) DEFAULT '' COMMENT '连接地址',
  `image` varchar(255) DEFAULT '' COMMENT '图片地址',
  `description` varchar(255) DEFAULT '' COMMENT '简介',
  `weight` tinyint(3) unsigned DEFAULT '0' COMMENT '排序',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COMMENT='轮播';
str;
		$sqls[] = "INSERT INTO `ebcms_slide` VALUES ('1', '第一张图', 'http://www.ebcms.com/', 'http://static.ebcms.com/img/slide/1.jpg', '么么哒第一张', '1');";
		$sqls[] = "INSERT INTO `ebcms_slide` VALUES ('2', '第2张图', 'http://www.ebcms.com/', 'http://static.ebcms.com/img/slide/2.jpg', '第二章么么哒', '1');";
		$sqls[] = "INSERT INTO `ebcms_slide` VALUES ('3', '第三章', 'http://www.ebcms.com/', 'http://static.ebcms.com/img/slide/3.jpg', '么么哒第三章啦', '1');";
		$sqls[] = "INSERT INTO `ebcms_slide` VALUES ('4', '第四幅图片', 'http://www.ebcms.com/', 'http://static.ebcms.com/img/slide/4.jpg', '买的美发店第四幅', '1');";
		foreach ($sqls as $sql) {
			$sql = str_replace('ebcms_', \mylib\Config::get('database.prefix'), $sql);
			\Ebcms::db() -> query($sql);
		}
		return true;
	},
	'uninstall' => function(){
		$sqls = [];
		$sqls[] = "DROP TABLE IF EXISTS `ebcms_slide`;";
		foreach ($sqls as $sql) {
			$sql = str_replace('ebcms_', \mylib\Config::get('database.prefix'), $sql);
			\Ebcms::db() -> query($sql);
		}
		return true;
	}
];